<?php //jQuery Validation ?>
<script type="text/javascript">
	$(document).ready(function(){
	     //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
     
        //Set height and width to mask to fill up the whole screen
        $('#loading').css({'width':maskWidth,'height':maskHeight,'position':'absolute','top':'0','left':'0','z-index':'1000'});

        $("#signup").click(function(e){
                    	
					$("#addmember-form").validate();
					e.preventDefault;
					if($("#addmember-form").valid()){ //register if form is valid
					    $("#signup").hide();
					    addmember($("#strFirstName").val(),$("#strLastName").val(),$("#strInstrument").val(),$("#month").val(),$("#day").val(),$("#year").val()); 
					
					}
		});
        
	});
		
	function addmember(_firstname,_lastname,_instrument,_month,_day,_year)
	{
		$.post(base_url + "users/add/", {
			strFirstName: _firstname,
			strLastName: _lastname,
			strInstrument: _instrument,
			dteBirthdate: _year+'-'+_month+'-'+_day
		}, function(response){

					$("#loading").hide();
					$("#signup").show();
				
				var res = $.parseJSON(response);
				if(res.success==0 || res.success==2)
				{
					$("#message-modal").html(res.message);
					$("#signup").show();
				}
				else
				{
					parent.document.location=parent.document.location;
				}	

			

		});
		setTimeout("clear_html()","5000");
		return false;
	}		
	
	function clear_html()
	{
		$('#register-modal .modal-error').html('');
	}
</script>